package com.xunji.xunji.module.account.ui.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;

import com.huanxiao.base.base.BaseFragment;
import com.huanxiao.base.view.GridViewForScrollView;
import com.xunji.xunji.R;
import com.xunji.xunji.module.account.bean.MenuInfo;
import com.xunji.xunji.module.account.ui.activity.MyActivity;
import com.xunji.xunji.module.account.ui.adapter.MenuAdapter;
import com.xunji.xunji.module.trace.ui.activity.TraceMapActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Paul on 2017/2/2.
 */

public class MenuFragment extends BaseFragment {

    private GridViewForScrollView svMenu;

    public static MenuFragment newInstance() {
        
        Bundle args = new Bundle();
        
        MenuFragment fragment = new MenuFragment();
        fragment.setArguments(args);
        return fragment;
    }
    @Override
    public int getLayoutID() {
        return R.layout.fragment_menu;
    }

    @Override
    public void initView(View view) {
        svMenu = fvById(view,R.id.sv_menu);
        MenuInfo menuInfo0 = new MenuInfo(0,R.drawable.ic_menu_jinruditu,"进入地图");
        MenuInfo menuInfo1 = new MenuInfo(1,R.drawable.ic_menu_lvxinggonglue,"旅行攻略");
        MenuInfo menuInfo2 = new MenuInfo(2,R.drawable.ic_menu_gerenzhongxin,"个人中心");
        MenuInfo menuInfo3 = new MenuInfo(3,R.drawable.ic_menu_shenghuofuwu,"生活服务");

        List<MenuInfo> list = new ArrayList<>();
        list.add(menuInfo0);
        list.add(menuInfo1);
        list.add(menuInfo2);
        list.add(menuInfo3);

        MenuAdapter adapter = new MenuAdapter(list,mActivity);
        svMenu.setAdapter(adapter);
        
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public void initData() {

    }

    @Override
    public void initBundleExtras(Bundle extras) {

    }

    @Override
    public void initListener() {
        svMenu.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position==0){
                    TraceMapActivity.start(mActivity);

                }else if (position==1){

                }else if (position==2){
                    MyActivity.start(mActivity);
                }else if (position==3){

                }
            }
        });
    }

    @Override
    public boolean isBindEventBus() {
        return false;
    }
}
